package com.test.service;

import com.test.tool.IdGeneratorSnowflake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Service
public class OrderService {

    @Autowired
    private IdGeneratorSnowflake idGenerator;

    public String getIDBySnowFlake(){
        ExecutorService threadTool = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 20; i++) {
            threadTool.submit(() -> {
                System.out.println(idGenerator.snowflakeId());
            });
        }
        threadTool.shutdown();

        return "hello snowflake";
    }
}
